package com.kc.data.common.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.kc.data.common.domain.model.KcGoodsOrderShipping;
import com.kc.data.common.mapper.KcGoodsOrderShippingMapper;
import com.kc.data.common.service.IKcGoodsOrderShippingService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * TODO
 *
 * @author zhangshuo
 * @version 1.0
 * @date 2020/12/12
 */
@Service
public class KcGoodsOrderShippingServiceImpl implements IKcGoodsOrderShippingService {
    @Resource
    KcGoodsOrderShippingMapper kcGoodsOrderShippingMapper;

    /**
     * 批量保存发货记录
     *
     * @param kcGoodsOrderShippingList
     */
    @Override
    public int saveBatch(List<KcGoodsOrderShipping> kcGoodsOrderShippingList) {
        for (KcGoodsOrderShipping kcGoodsOrderShipping : kcGoodsOrderShippingList) {
             kcGoodsOrderShippingMapper.insert(kcGoodsOrderShipping);
        }
        return 1;
    }

    @Override
    public List<KcGoodsOrderShipping> getList(Integer orderId) {
        if (orderId != null && orderId > 0) {
//            KcGoodsOrderShipping shipping = new KcGoodsOrderShipping();
//            shipping.setOrderId(orderId);
            LambdaQueryWrapper<KcGoodsOrderShipping> wrapper = new LambdaQueryWrapper<>();
            wrapper.eq(KcGoodsOrderShipping::getOrderId,orderId);
            return kcGoodsOrderShippingMapper.selectList(wrapper);
        }
        return null;
    }
}
